package main

import (
	"os"

	"daxin.my/test-netserver/api"
	"daxin.my/test-netserver/middleware"
	"daxin.my/test-netserver/protocol"
	"daxin.my/test-netserver/quartz"
)

const (
	// 环境变量
	Quartz = "QUARTZ"
)

func main() {
	middleware.InitMiddlewares()
	protocol.InitClient()
	protocol.InitServer()

	if os.Getenv(Quartz) == "true" {
		quartz.StartJob()
		defer quartz.StopJob()
	}

	for _, client := range api.MiddlewareClients {
		if client != nil {
			defer client.Close()
		}
	}

	for _, client := range api.ProtocolClients {
		if client != nil {
			defer client.Close()
		}
	}

	select {}
}
